<template>
  <div class="myCharts" style="width: 100%; height: 90%;">
    <div ref="myCharts" style="width: 100%; height: 90%; margin: 0 auto" />
  </div>
</template>
<script>
// 1、引入echarts图表库
import * as echarts from 'echarts'
export default {
  props: {
    monthlyOrderList: {
      type: Array,
      required: true
    }
  },
  data() {
    return {}
  },
  watch: {
    monthlyOrderList() {
      this.myCharts.setOption({
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: {},
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: this.monthlyOrderList.map(v => v.dateTime)
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: this.monthlyOrderList.map(v => v.orderNumber),
            type: 'line',
            areaStyle: {
              color: '#fcece9'
            },
            lineStyle: {
              color: '#f85c38'
            }
          }
        ]
      })
    }
  },
  mounted() {
    this.myCharts = echarts.init(this.$refs.myCharts)
    this.myCharts.setOption({
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: this.monthlyOrderList.map(v => v.dateTime)
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          data: this.monthlyOrderList.map(v => v.orderNumber),
          type: 'line',
          areaStyle: {
            color: '#fcece9'
          },
          lineStyle: {
            color: '#f85c38'
          }
        }
      ]
    })
  }
}
</script>
